Skip to content

format: rewrite the type schemas - #424

Draft
gnidan wants to merge 25 commits into
mainfrom
format-type-rewrite
Draft

gnidan wants to merge 25 commits into
mainfrom
format-type-rewrite

Conversation

@gnidan

@gnidan gnidan commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

This rewrites the ethdebug/format/type schemas for #282. A type now says what a value is. The pointer says where the value's bytes are, so widths, sizes and counts leave the types. Interpretations (decoders) turn a type and a pointer into a value, and a language that needs more can add its own kinds.

The old kinds go away in this release. Nothing is deprecated.

Kinds

Elementary:

  • ethdebug/format/type/elementary/number replaces uint, int, ufixed and fixed: optional signed (default false) and places (default 0). No bits.
  • ethdebug/format/type/elementary/address absorbs contract: optional payable; an optional definition makes the address a contract reference, and the definition carries the library / interface hints.
  • ethdebug/format/type/elementary/flags is new: a set of named members (Vyper flag). Bit i is the bit with the value 2**i.
  • bytes loses size. enum requires one or more unique string values. bool and string are unchanged apart from label.

Complex:

  • ethdebug/format/type/complex/struct absorbs tuple (members without names). An empty struct is legal.
  • ethdebug/format/type/complex/variant is new: cases of {name, discriminant, payload?}. The discriminant is compared as an unsigned integer, so 0 and "0x00" are the same discriminant.
  • array loses count. function takes top-level parameters and returns lists (returns: [] means no values) in place of contains; an external function may name its contract as an address with a definition. alias and mapping keep their shape.

Every type may carry label, the type as the language spells it (uint256, bytes32, address[10]). It is for display only.

Each kind's description states its standard interpretation, except function, which has none yet. Realizations, which describe which regions of a pointer hold which parts of a type, come in a later PR.

Unknown kinds

The base rule (class and contains) is for kinds that a consumer does not know. An unknown kind gives class, and an unknown complex kind must put its child types under contains. A consumer dispatches on a known kind by kind. class stays optional on known kinds, and variant and function must not give contains, so without class these two look elementary to the base rule. Their schema examples give class: complex. A base complex type may now omit contains when it gives class: complex, so an unknown kind can hold a known variant or function.

Producers and consumers

This is breaking for both. A type with an old kind validates only as an unknown kind: it must give class, and it then has no meaning. The format reserves no kind names. bits, size and count still pass validation as extra fields, but they no longer mean anything. A function or variant with contains does not validate.

  • @ethdebug/format: the TS types and guards follow the new kinds; the old ones are removed. The guards now also reject an elementary type with contains and a type reference with fields other than id, as the schemas do.
  • bugc emits the new kinds with a label (for example {kind: "number", signed: true, label: "int8"}, or array<uint256, 3> for an array). It also stops emitting length on arrays, a field the old schema did not define.
  • The tracer shows a type's label, or else its kind.
  • solc still emits the old kinds in its resources types table. Conformance now validates solc's resources with an empty types table, and a tripwire test fails once solc's table validates (conformance: solc emits the old type kinds #423).
  • The spec pages and docs describe the new kinds.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://ethdebug.github.io/format/pr-preview/pr-424/

Built to branch gh-pages at 2026-11-24 05:39 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Flags count bits from the least significant bit, as enum reads its
index. A variant compares discriminants as unsigned integers, so 0 and
"0x00" are the same discriminant. Array and struct now state their
standard interpretations. Function says that it has none yet.
An unknown complex kind must give `contains`, so a consumer that does
not know the kind can find its child types. Variant and function must
not give `contains`; they give their parts in their own fields. Their
examples now give `class: complex`, and the base and type schemas say
that the base rule is for kinds a consumer does not know.

Also remove a stale `discriminant` field from a test fixture.
A known elementary kind must not give `contains`, and a type reference
must not have fields other than `id`. The schemas rejected both; the
guards accepted them. A value with an `id` is now a specifier only if
it is a reference, as the specifier schema says.
… reads

The docs now say that a consumer dispatches on a known kind by `kind`,
and that an unknown complex kind gives `contains`. They also give the
flags bit order and how a variant compares discriminants.
A type with an old kind still validates as an unknown kind if it gives
`class`; it then has no meaning. The format reserves no kind names.
The entries now also give the flags bit order, the variant discriminant
comparison, and the guard changes.
An array type had no label, so a fixed-size array and a dynamic array
gave the same type object. The label now gives the BUG spelling, e.g.
array<uint256, 3>.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant